<template>
   <!-- 输入框 -->
   <header class="header">
      <h1>龙年大吉记事本</h1>
      <input @keyup.enter="add" placeholder="请输入任务" class="new-todo" v-model="todoName" />
      <button @click="add" class="add">添加任务</button>
    </header>
</template>

<script>
export default {
  data(){
    return{
      todoName:''
    }   
},
methods:{
  add(){
    if(this.todoName.trim()===''){
        alert('请输入任务')
        return
      }
    this.$emit('addFn',this.todoName)
    this.todoName=''
  }
}
}
</script>

<style>

</style>